﻿using BaseUtils.AppConfig;
using BaseUtils.Helper;
using S7.Net;

namespace DeviceManage.PLC
{
    public class PLCFactory
    {

        /// <summary>
        /// 实例化PLC
        /// </summary>
        /// <returns></returns>
        public static IPLCHelper InstantiationPLC(PlcInfo plc)
        {
            CpuType cpu = ConvertHelper.ToEnum<CpuType>(plc.cpuType);
            switch (cpu)
            {
                case CpuType.S7200:
                case CpuType.Logo0BA8:
                case CpuType.S7200Smart:
                case CpuType.S7300:
                case CpuType.S7400:
                case CpuType.S71200:
                case CpuType.S71500:
                    PLCHelper pLCHelper = new PLCHelper();
                    pLCHelper.Config = plc;
                    pLCHelper.Link();
                    return pLCHelper;
                default:
                    return null;
            };
        }
    }
}
